package com.zzedu.web.controller;

import com.zzedu.common.annotation.Log;
import com.zzedu.common.enums.BusinessType;
import com.zzedu.common.enums.OperatorType;
import com.zzedu.device.req.*;
import com.zzedu.device.rsp.*;
import com.zzedu.manager.ITeacherStudentManager;
import com.zzedu.result.Result;
import com.zzedu.utils.BaseReq;
import com.zzedu.utils.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 教师学生Controller
 */
@RestController
@RequestMapping("teacherStudent")
public class TeacherStudentController {
    @Autowired
    ITeacherStudentManager teacherStudentManager;

    /**
     * 班级学生-学习情况列表
     *
     * @param req
     * @return
     */
    @PostMapping(value = {"/stuLearnList"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "班级学生-学习情况列表", businessType = BusinessType.APP_STUDENT, operatorType = OperatorType.MOBILE)
    public Result<List<ApiStuLearnVO>> stuLearnList(@Validated @RequestBody BaseReq<TeacherStuClassPageList> req) {
        return teacherStudentManager.stuLearnList(req.getData());
    }


    /**
     * 班级学生-学习详情
     *
     * @param req
     * @return
     */
    @PostMapping(value = {"/stuLearnNodeInfo"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "班级学生-学习详情", businessType = BusinessType.APP_STUDENT, operatorType = OperatorType.MOBILE)
    public Result<List<ApiStuLearnNodeInfoVO>> stuLearnNodeInfo(@Validated @RequestBody BaseReq<TeacherStuClassInfo> req) {
        return teacherStudentManager.stuLearnNodeInfo(req.getData());
    }

    /**
     * 小程序-作业发送列表
     *
     * @param req
     * @return
     */
    @PostMapping(value = {"/distributeList"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "班级学生-作业发送列表", businessType = BusinessType.APP_DEVICE_TEACHER, operatorType = OperatorType.MOBILE)
    public Result<PageData<ApiDistributeList>> distributeList(@Validated @RequestBody BaseReq<QueryPageDistributeList> req) {
        return teacherStudentManager.distributeList(req.getData());
    }
    /**
     * 小程序-派发作业
     *
     * @param req
     * @return
     */
    @PostMapping(value = {"/distribute"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "班级学生-派发作业", businessType = BusinessType.APP_DEVICE_TEACHER, operatorType = OperatorType.MOBILE)
    public Result distribute(@Validated @RequestBody BaseReq<Distribute> req) {
        return teacherStudentManager.distribute(req.getData());
    }

    /**
     * 小程序-作业发送历史
     *
     * @param req
     * @return
     */
    @PostMapping(value = {"/distributeHistory"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "班级学生-作业发送历史", businessType = BusinessType.APP_DEVICE_TEACHER, operatorType = OperatorType.MOBILE)
    public Result<PageData<ApiDistributeHistory>> distributeHistory(@Validated @RequestBody BaseReq<QueryPageDistributeHistory> req) {
        return teacherStudentManager.distributeHistory(req.getData());
    }

    /**
     * 老师信息
     *
     * @param req
     * @return
     */
    @PostMapping(value = {"/teacherInfo"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "老师信息", businessType = BusinessType.APP_DEVICE_TEACHER, operatorType = OperatorType.MOBILE)
    public Result<ApiTeacherInfoVO> teacherInfo(@Validated @RequestBody BaseReq req) {
        return teacherStudentManager.teacherInfo();
    }
}
